﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Willow.Common
{
    public static class NetHelper
    {
        /// <summary>
        /// 获得当前请求的Ip地址
        /// </summary>
        /// <returns></returns>
        public static string GetRequestIP()
        {
            string ip;
            var request = HttpContext.Current.Request;
            if (request.ServerVariables["HTTP_VIA"] != null)
            {
                ip = request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
            }
            else
            {
                ip = request.ServerVariables["REMOTE_ADDR"].ToString();
            }
            return ip;

        }
    }
}
